/**
 * 自定义函数
 * */


//选项
function showOne(){
    var formData = {
        id: id,
    };
    $.ajax({
        type: apiMethod,
        url: apiDomain + 'wh/one',
        data: formData,
        success: function (res) {
            console.log(res);
            if (res.code < 0) {
                msgPop({msg: res.msg});
                return
            }
            oneHtml(res.data.data);
        },
        error: function () {
            console.log('网络错误');
        }
    });
}
//详情HTML
function oneHtml(d){
    //日期
    $('#in_day')[0].value = d.in_day;
    //项目
    $('#item_name0')[0].value = d.item_name;
    //任务
    $('#task_name')[0].value = d.task_name;
    $('#delay_total')[0].value = d.delay;
    //工时项
    var dwh = d.whList, ii, child;
    var h, i;
    h = '';
    for (i = 0; i < dwh.length; i ++) {
        child = dwh[i].child;
        if (child.length > 0) {
            h += '<style type="text/css">.formGroup { margin: 10px 3vw; border: 1px solid #eee; clear: both; } .formBox { margin: 20px; height: 200px; border: 1px solid #eee; clear: both; } .gsSub { padding: 0 10px; padding-top: 5px; color: #0088CC; float: right; } .wh-child { width: 85%; }</style>';
            h += '<div class="formGroup">';
            h += '<div class="row cl">';
            h += '<label class="form-label col-xs-4 col-sm-2">';
            h += '工时项：';
            h += '</label>';
            h += '<div class="formControls col-xs-8 col-sm-9">';
            h += '<input type="text" class="input-text wh-child" value="' + dwh[i].config_title + '" disabled/>';
            h += '</div>';
            h += '</div>';
            h += '<div class="row cl">';
            h += '<label class="form-label col-xs-4 col-sm-2">';
            h += '合计工时：';
            h += '</label>';
            h += '<div class="formControls col-xs-8 col-sm-9">';
            h += '<input type="text" class="input-text wh-child" value="' + dwh[i].delay + '" readonly/>';
            h += '</div>';
            h += '</div>';
        }
        for (ii = 0; ii < child.length; ii ++) {
            h += '<div class="formBox">';
            h += '<div class="row cl">';
            h += '<label class="form-label col-xs-4 col-sm-2">';
            h += '工作内容：';
            h += '</label>';
            h += '<div class="formControls col-xs-8 col-sm-9">';
            h += '<input type="text" class="input-text wh-child" value="' + child[ii].cnt_str + '" disabled/>';
            h += '</div>';
            h += '</div>';
            h += '<div class="row cl">';
            h += '<label class="form-label col-xs-4 col-sm-2">';
            h += '开始时间：';
            h += '</label>';
            h += '<div class="formControls col-xs-8 col-sm-9">';
            h += '<input type="text" class="input-text wh-child" value="' + child[ii].starthour + '" disabled/>';
            h += '</div>';
            h += '</div>';
            h += '<div class="row cl">';
            h += '<label class="form-label col-xs-4 col-sm-2">';
            h += '结束时间：';
            h += '</label>';
            h += '<div class="formControls col-xs-8 col-sm-9">';
            h += '<input type="text" class="input-text wh-child" value="' + child[ii].endhour + '" disabled/>';
            h += '</div>';
            h += '</div>';
            h += '<div class="row cl">';
            h += '<label class="form-label col-xs-4 col-sm-2">';
            h += '时长：';
            h += '</label>';
            h += '<div class="formControls col-xs-8 col-sm-9">';
            h += '<input type="text" class="input-text wh-child" value="' + child[ii].delay_str + '" disabled/>';
            h += '</div>';
            h += '</div>';
            h += '</div>';
        }
        h += '</div>';
    }
    $('#formEdit').html(h);
}